package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.ProcessMediaDto;
import com.cssw.fyzb.wap.model.vo.ProcessMediaVo;
import com.cssw.fyzb.wap.model.vo.UploadSigVo;
import com.cssw.fyzb.wap.model.vo.WxOperIdVo;
import com.cssw.fyzb.wap.service.ResourcesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description:
 * @author: zzf
 * @time: 2020/12/23 16:53
 */
@Api(description = "共用相关的接口")
@RestController
@RequestMapping("/resour")
public class ResourcesController {

    @Autowired
    private ResourcesService resourcesService;

    @ApiOperation(value = "图片上传")
    @RequestMapping(value = "/imgFile", method = RequestMethod.POST)
    public AjaxPage imgFile(@RequestParam MultipartFile[] files) throws Exception {
        return resourcesService.imgFile(files);
    }

    @ApiOperation(value = "比例")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataType = "string", required = true)
    })
    @GetMapping("proportion")
    public AjaxData proportion(String paramCode) throws Exception {
        return resourcesService.proportion(paramCode);
    }

    @ApiOperation(value = "处理视频信息")
    @RequestMapping(value = "/processMedia", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<ProcessMediaVo> processMedia(@RequestBody ProcessMediaDto dto) {
        return resourcesService.processMedia(dto.getFileId());
    }


    @ApiOperation(value = "获取上传签名")
    @RequestMapping(value = "/getUploadSig", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<UploadSigVo> getUploadSig() {
        return resourcesService.getUploadSig();
    }

    @ApiOperation(value = "获取operId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "参数编码", paramType = "query", dataType = "string", required = true)
    })
    @RequestMapping(value = "/getOperId", method = RequestMethod.GET)
    public AjaxData<WxOperIdVo> getOperId(String code) {
        return resourcesService.getOperId(code);
    }
}
